home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / Additions ƒ / FinishJobMessage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  3.5 KB  |  131 lines  |  [TEXT/MPS ]

  1. /* ------------------------------------------------------------------------------
  2.  
  3.     FILENAME
  4.         FinishJobMessage.c
  5.  
  6.     DESCRIPTION
  7.         This file contains the message procedure that will be invoked when the Printing Manager
  8.         issues the FinishJob message.  The routine which is called is FinishJobMessageProc.
  9.         Depending upon the effects the user selected in the Addition's Print dialog panel, 
  10.         FinishJobMessageProc will invoke routines in the Additions.c file to produce the
  11.         desired effects.
  12.  
  13.     COPYRIGHT
  14.         Copyright Apple Computer, Inc. 1991
  15.         All rights reserved. 
  16.     
  17.     INTERFACE ROUTINES
  18.         FinishJobMessageProc
  19.  
  20.     MODIFICATION HISTORY
  21.         05/15/91            ALA                Initial Implementation
  22.          6/14/96            cn                    Updated to support Universal Interfaces 2.1.
  23.  
  24.  
  25. ------------------------------------------------------------------------------- */
  26.  
  27. #include <Types.h>
  28. #include <Quickdraw.h>
  29. #include <Memory.h>
  30. #include <Resources.h>
  31. #include <Dialogs.h>
  32. #include <TextEdit.h>
  33. #include <OSUtils.h>
  34. #include <Packages.h>
  35. #include <ToolUtils.h>
  36. #include <Menus.h>
  37. #include <String.h>
  38. #include <Strings.h>
  39. #include <Printing.h>
  40.  
  41. #include <GXGraphics.h>
  42. #include <GraphicsLibraries.h>
  43. #include <FontLibrary.h>
  44.  
  45. #include <Collections.h>
  46. #include <GXMessages.h>
  47.  
  48. #include    <GXPrinting.h>
  49.  
  50. #include "Utilities.h"
  51. #include "Additions.h"
  52.  
  53.  
  54. /*================================== MESSAGE INTERFACE ROUTINES ==================================*/
  55.  
  56.  
  57. /* ===== FinishJobMessageProc =====
  58.  
  59.     FinishJobMessageProc is the extension's routine which will be invoked when Printing issues a 
  60.     FinishJob message.  This routine checks to see if a cover page should be added
  61.     at the end of the document. If so, it will call ComposeCoverPage 
  62.     to generate a page shape, and Send_SpoolPage to spool the cover page to disk.  
  63.     Regardless of whether a cover page is added to the file, this routine also calls 
  64.     Forward_FinishJob to close down the spool file.
  65. */
  66. OSErr FinishJobMessageProc(void)
  67. {
  68.     
  69.     OSErr                         anErr = noErr;
  70.     gxShape                        coverPage = nil;
  71.     Collection                    jobCollection;
  72.     AdditionsCollection        additionsConfig;
  73.     
  74.     gxJob printJob = GXGetJob();
  75.     
  76.     /* Get reference to the print Job's collection */
  77.     jobCollection = GXGetJobCollection(printJob);
  78.     
  79.     /* Fetch the Additions's collection we created at Print dialog time */
  80.     anErr = GetCollectionItem (jobCollection,
  81.                                         kAdditionsCollectionType,
  82.                                         gxPrintingTagID,
  83.                                         nil,
  84.                                         &additionsConfig);
  85.     if (anErr == noErr)
  86.     {
  87.         /* If user selected the "cover page last" option, add the cover page to the spool file */
  88.         if (    (additionsConfig.addCoverPage)                         && 
  89.                 (additionsConfig.coverPage ==    kCoverPageLast)
  90.             )
  91.         {
  92.             gxFormat                    theFormat;
  93.             gxJobInfo                printerInfo;
  94.     
  95.             /* Get the format we should use for the cover page */
  96.             theFormat = GXGetJobFormat(printJob, 1);
  97.             
  98.             /* Get the general printing info. collection item */
  99.             anErr = GetCollectionItem (jobCollection,
  100.                                                 gxJobTag,
  101.                                                 gxPrintingTagID,
  102.                                                 nil,
  103.                                                 &printerInfo);
  104.             if (anErr == noErr)
  105.             {
  106.                 /* Create the cover page shape */
  107.                 anErr = ComposeCoverPage(&coverPage, theFormat, &printerInfo);
  108.                 if (anErr == noErr)
  109.                 {
  110.                     /* Spool the shape into the file */
  111.                     anErr = Send_GXPrintPage(theFormat, coverPage);
  112.             
  113.                     /* Dump the shape since we no longer need it */
  114.                     GXDisposeShape(coverPage);
  115.                 }
  116.             }
  117.         }
  118.     }
  119.     else    //    T => no config; don't do anything
  120.         anErr = noErr;
  121.  
  122.     if (anErr == noErr)
  123.     {
  124.         /* Make sure the job is finished properly */
  125.         anErr = Forward_GXFinishJob();
  126.     }
  127.  
  128.     return(anErr);
  129. }
  130. /* FinishJobMessageProc */
  131.